home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / TWarnDialog.cp < prev    next >
Encoding:
Text File  |  1992-02-21  |  3.2 KB  |  108 lines  |  [TEXT/MPS ]

  1. #pragma segment warning
  2. //**********************************************************************
  3. //    The TWarning class methods.
  4. //**********************************************************************
  5. //--------------------------------------------------------------------------------------------------
  6. //     Initialize the Dialog
  7. //--------------------------------------------------------------------------------------------------
  8. void TWarning::IWarning(short which,char * parm)
  9.     {
  10.     msg = new char[256];
  11.     switch(which)
  12.         {
  13.         case 0 :
  14.             sprintf(msg,"The requested point is beyond the bounds of this view.\nMaximum views point is 400 x 400\n%s",parm);
  15.             fIconNumber = 136;
  16.             break;
  17.         case 1 :
  18.             sprintf(msg,"The %s boundries MUST have an Equal Number of Segment Points",parm);
  19.             fIconNumber = 129;
  20.             break;
  21.         case 2 :
  22.             sprintf(msg,"The %s boundries MUST have an Equal Number of Segment Points",parm);
  23.             fIconNumber = 130;
  24.             break;
  25.         case 3 :
  26.             sprintf(msg,"Select a Segment to Edit");
  27.             fIconNumber = 0;
  28.             break;
  29.         case 4:
  30.             sprintf(msg,"...No Cell Selected...\nClick the Mouse Inside a Cell to Select.");
  31.             fIconNumber = 137;
  32.             break;
  33.         case 5:
  34.             sprintf(msg,"...No Obstacle Created...\nShow Grid and Click Inside a Cell.");
  35.             fIconNumber = 137;
  36.             break;
  37.         case 6:
  38.             sprintf(msg,"...Can Not Read File...");
  39.             fIconNumber = NULL;
  40.             break;
  41.         case 7:
  42.             sprintf(msg,"...Can Not Delete a Grid Point With an Opposing Segment Point...\nDelete the Segment Point on Opposite Boundry.");
  43.             fIconNumber = NULL;
  44.             break;
  45.         case 8:
  46.             sprintf(msg,"Can Not Add a Grid Line Through a(n) %s\nPlease Delete the Connecting %s(s) Before Adding the Line.",parm,parm);
  47.             if (strcmp(parm,"Obstacle") == 0)
  48.                 fIconNumber = 138;
  49.             else
  50.                 fIconNumber = 139;
  51.             break;
  52.         case 9:
  53.             sprintf(msg,"Can Not Delete a Grid Line Through a(n) %s\nPlease Delete the Connecting %s(s) Before Deleting the Line.",parm,parm);
  54.             if (strcmp(parm,"Obstacle") == 0)
  55.                 fIconNumber = 138;
  56.             else
  57.                 fIconNumber = 139;
  58.             break;
  59.         }
  60.     }
  61.     
  62. // --------------------------------------------------------------------------------------------------
  63. //     Show the Dialog
  64. // --------------------------------------------------------------------------------------------------
  65. void TWarning::ShowWarning(void)
  66.     {    
  67.     Rect                iconRect;
  68.     TWindow         * aWindow;
  69.     TStaticText    * warnUser;
  70.     TIcon             * theIcon;
  71.     CIconHandle    cIcon;
  72.     IDType             dismisser;
  73.  
  74.     aWindow    = this->GetWindow();                                                // get the window for this object
  75.     warnUser    = (TStaticText *) aWindow->FindSubView('outb');        // static text field
  76.     theIcon     = (TIcon *) aWindow->FindSubView('micn');
  77.  
  78.     this->fDefaultItem = 'OKOK';                                                        // set defaults
  79.     this->fCancelItem = 'CNCL';
  80.  
  81.     iconRect.top            = 8;
  82.     iconRect.left            = 8;
  83.     iconRect.bottom    = 40;
  84.     iconRect.right        = 40;
  85.     
  86.     cIcon = GetCIcon(fIconNumber);                                                    // get the icon
  87.     if (cIcon != NULL)
  88.         {
  89.         HLock((Handle) cIcon);
  90.         theIcon->fRsrcID = fIconNumber;
  91.         theIcon->SetIcon((Handle) cIcon,true);
  92.         }
  93.             
  94.     StringPtr dText = c2pstr(msg);    
  95.     warnUser->SetText(dText,false);
  96.         
  97.     dismisser = this->PoseModally();
  98.     if (cIcon != NULL)
  99.         HUnlock((Handle) cIcon);
  100.         
  101.     aWindow->Close();
  102.     }
  103.  
  104. pascal void TWarning::Free(void)
  105.     {
  106.     delete msg;
  107.     inherited::Free();
  108.     }